Assignment 1: Getting Acquainted with Java Swing

This is an PAIRED assignment.

Objective

The goal of this assignment is to familiarize you with the Swing UI toolkit in Java.
Future assignments will build on this first assignment, so it's important for you to get this one right and to understand what you have done.

Description

During the first part of this course you will be creating a journal application that allows you to track and record energy footprint and sustainable living practices. When completed, the application will allow you to add entries involving various media, annotate them, and organize them in a variety of ways.Later on you will be able to incorporate simple sensor readings and plot their results. The application will consist of the following:
  • a note taking pane for adding journal entries (organized by date, and including photos);
  • a calendar view ; and
  • an energy consumption visualization tool.

Dont worry! You wont be doing all this at once. In this assignment, you will create the basic "shell" of the application. The goal of this homework is to simply give you some practice writing basic Swing GUIs (using existing components instead of creating your own), and to make sure that your environment is set up correctly.
Your application must create a new window (a_JFrame_component) when it starts). This window will contain (variably) all the views mentioned above. As you get more comfortable with programming you may choose to combine these in various panes within the same window. At the beginning you will put these in separate associated_JPanels.
The components and behaviors that your application must provide in this window are:
  • A menu bar with the following menus:
    • File:
      • Import image/Graph (imports a new graph and displays it in the main content area, eventually)
      • Import Journal File (imports a saved journal file into the album and displays it)
      • Delete Image/Graph (deletes the current photo, eventually)
      • New entry (creates a new journal entry)
      • Delete entry (deletes current entry)
      • Save journal
      • Exit (quits the application)
    • View:
      • Show/Hide Energy Use
      • Initially, the menu item should be labeled "Show Energy Use". Selecting it should display a second JFrame, the contents of which can be empty for now (for example, a JPanel with size set to 300x400 or something). This second frame must have a working Close box on it that dismisses the frame. While the second frame is displayed, the menu should be labeled "Hide Energy Use" and selecting it should make the second frame disappear. If the frame is made invisible (whether through the menu or clicking on the Close box on the frame), the menu should change back to "Show Energy Use." (The “energy use” frame will contain the view(s) of your energy consumption from eventual sensor readings and user-entered data. You’ll be designing this later).
  • In the main portion of the window should be your content area. For now (since we haven't written the content area component yet), this can simply be a blank JPanel set to have a reasonable size.
  • Along the bottom of the frame should be a label that will be used to display status messages.
  • Along the left side of the frame will be a collection of tools that will (eventually) operate on the content. These tools should include:
    • A collection of toggle buttons (JToggleButton, but read on for more details): at least 4, that we'll use to tag the journal entry. You can come up with your own tags for these, such as "Home," "Work," "Commuting," "Tips," etc). Note that the behavior I'm after here is that you should be able to "tag" entries with zero or more of these flags. So, it's fine with me if you want to use a different type of component that gives a similar behavior but looks better (check boxes for instance).However, these buttons do not have to be active at this point except for providing a message about which is pushed.
    • Page forward and backward controls
  • A small calendar view (this can just be a static image for the moment.)IF you cant import an image, just make a blank pane of an appropriate size and label it “Calendar”.

Your application must behave reasonably when resized, moved, etc.

For all of the controls, selecting them should display a message in the status label describing what control was just activated.
This should not be a hard assignment. Again, the main goal is to ensure that you understand how to structure a basic Swing application, how to write callbacks, and how to respond to events such as windows appearing and disappearing (to change menu labels, for instance).

Deliverable

This is an PAIREd assignment; follow the guidelines for Paired Programming assignments. While you can use any development environment you choose, you are not allowed to use GUI builder type tools (like JBuilder or Eclipse GUI Builder).
Here are the details for how to turn in the assignment. We'll be following this structure for all of the turn-ins:
  1. Your application. Make sure your program is runnable EITHER from the Eclipse project folder or from the command line using the command "java energyJournal". Use exactly this name (with no package) for the main class to make things easier on me and the TAs.

a.Please take care to remove any platform dependencies, such as hardcoded Windows path names or dependence on a particular look-and-feel that may not exist on all platforms. Also, if you use any images in your application, please make sure that you include these in your ZIP file and that your code will refer to them and load them properly when from from inside the directory that's created when I unZIP your code.
  1. Design document.
  2. Archive everything into a Zip file with the .zip suffix. Currently - for this assignment - submission instructions will be posted later, as we do not have an electronic drop-box yet.

Grading for this assignment, and future assignments, will roughly follow this breakdown:
  • 60% functionality
  • 40% good architectural design, coding style, commenting

Please let the TA or me know if you have any questions.